// This file is part of OpenMeca, an easy software to do mechanical simulation.
//
// Author(s)    :  - Damien ANDRE  <openmeca@gmail.com>
//
// Copyright (C) 2012 Damien ANDRE
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include <QApplication>
#include <iostream>

#include "OpenMeca/Gui/WidgetBool.hpp"
#include "OpenMeca/Util/Dimension.hpp"
#include "OpenMeca/Util/Unit.hpp"

namespace OpenMeca
{
  namespace Gui
  {
    WidgetBool::WidgetBool(QWidget* parent)
      :QWidget(parent),
       WidgetInterface<bool>(*parent)
    {
      Ui::WidgetBool::setupUi(this);
    }
    
    WidgetBool::~WidgetBool()
    {
    }


     void 
     WidgetBool::Init()
    {
      const bool value =  WidgetInterface<bool>::GetValue();
      if (value)
	checkBox_->setCheckState(Qt::Checked);
      else
	checkBox_->setCheckState(Qt::Unchecked);
    }
    

    void 
    WidgetBool::SetLabel(const QString& str)
    {
      checkBox_->setText(str);
    }
   
    bool
    WidgetBool::Check()
    {
      if (checkBox_->checkState() == Qt::Checked)
	WidgetInterface<bool>::GetCopy() = true;
      else if (checkBox_->checkState() == Qt::Unchecked)
	WidgetInterface<bool>::GetCopy() = false;
      else
	assert(0);

      return true;
    }

  }
}


